package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.CustomerService;
import com.juneng.mapper.CustomerServiceMapper;
import com.juneng.service.ICustomerServiceService;
import com.juneng.dto.CustomerServiceDto;
import com.juneng.dto.CustomerServiceQueryDto;
import com.juneng.vo.CustomerServiceVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 意见反馈 服务实现类
 *
 * @author zds
 * @since 2021-07-19
 */
@Service
@AllArgsConstructor
public class CustomerServiceServiceImpl implements ICustomerServiceService {

    protected CustomerServiceMapper customerServiceMapper;
    @Override
    public IPage<CustomerServiceVo> page(CustomerServiceQueryDto dto) {
        IPage<CustomerServiceVo> page = Condition.getPage(dto);
        return customerServiceMapper.page(page,dto);
    }

    @Override
    public List<CustomerService> list(CustomerServiceQueryDto dto) {
        QueryWrapper<CustomerService> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,CustomerService.class));
        return customerServiceMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(CustomerServiceDto dto) {
        return customerServiceMapper.insert(BeanCopyUtils.copy(dto,CustomerService.class));
    }

    @Override
    public Integer updateById(CustomerServiceDto dto) {
        return customerServiceMapper.updateById(BeanCopyUtils.copy(dto,CustomerService.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return customerServiceMapper.deleteBatchIds(toIntList);
    }

    @Override
    public CustomerService getById(Integer id) {
        return customerServiceMapper.selectById(id);
    }

    @Override
    public CustomerService customerService(CustomerServiceDto dto) {
        CustomerService customerService = customerServiceMapper.selectOne(new LambdaQueryWrapper<CustomerService>().eq(CustomerService::getCustomerServiceId, dto.getCustomerServiceId()));
        return customerService;
    }
}
